home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / hypercar / xfcn / spttool.cpt / Support Tools eXternals 1.2.5 / card_37175.txt < prev    next >
Text File  |  1990-11-13  |  2KB  |  55 lines

  1. -- card: 37175 from stack: in.5
  2. -- bmap block id: 2389
  3. -- flags: 0000
  4. -- background id: 3858
  5. -- name: ApplMemory
  6. ----- HyperTalk script -----
  7. on HideObjects
  8.   hide cd btn "Try It!"
  9. end HideObjects
  10.  
  11. on ShowObjects
  12.   show cd btn "Try It!"
  13. end ShowObjects
  14.  
  15.  
  16. -- part 1 (button)
  17. -- low flags: 00
  18. -- high flags: A002
  19. -- rect: left=82 top=185 right=219 bottom=175
  20. -- title width / last selected line: 0
  21. -- icon id / first selected line: 0 / 0
  22. -- text alignment: 1
  23. -- font id: 0
  24. -- text size: 12
  25. -- style flags: 8192
  26. -- line height: 16
  27. -- part name: Try it!
  28. ----- HyperTalk script -----
  29. on mouseUp
  30.   global errGlobal
  31.   put ApplMemory("noDialog:errGlobal") into memAvail
  32.   if errGlobal Γëá empty then
  33.     answer "Error: ΓÇ£" & errGlobal & "ΓÇ¥"
  34.     put empty into errGlobal
  35.   else
  36.     answer "You have" && memAvail && "bytes available for launching."
  37.   end if
  38. end mouseUp
  39.  
  40.  
  41.  
  42.  
  43. -- part contents for background part 38
  44. ----- text -----
  45. 3/50
  46.  
  47. -- part contents for background part 20
  48. ----- text -----
  49.      An XFCN which returns the size (in bytes) of the largest block of contiguous memory available to any new application.  This information is especially helpful when attempting to launch an application, because HyperCard doesn't check the available memory before trying a luanch under MultiFinder.  If the launch fails, HC doesn't indicate that anything has happened, so there is no simple way for a script to determine if a launch has been successful.  By comparing the amount of memory available with the amount required by the program to be launched (see the XFCN "ApplSize" in this stack) you can predict whether a launch attempt will be successful or not (see note below).  The XFCN also works under single Finder and returns the maximum amount of memory that an application could use.
  50.  
  51.      Calling syntax : ApplMemory(<ΓÇ£noDialogΓÇ¥:errorGlobal>)
  52.  
  53.      Returns: the number of bytes free.
  54.  
  55.      Note:  under MultiFinder this XFCN returns results which vary from the number reported by 'About the FinderΓǪ' by about 10% (always higher), although the number varies.  Comparing the SIZE resource with the amount of free memory reported, the launch fails when there is as little as 60K difference (SIZE = 1000, MFMax = 1060) or as much as 90K difference (SIZE = 4072, MFMax = 4162).  In our scripts we warn the user that the launch attempt MAY fail when the amount required is within 10% of the amount available.